<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专辑列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>专辑id：</p>
                                <input type="text" name="albumId"/>
                            </li>
                            <li>
                                <p>专辑名称：</p>
                                <input type="text" name="title"/>
                            </li>
                            <li>
                                <p>上线状态 ：</p>
                                <select name="onlineState">
                                    <option value="">所有</option>
                                    <option value="1">上线</option>
                                    <option value="0">下线</option>
                                </select>
                            </li>
                            <li>
                                <p>分类：</p>
                                <select id="classId" name="classId">
                                    <option value="">所有</option>
                                    <option th:each="classification : ${classificationList}" th:text="${classification['className']}" th:value="${classification['classId']}" th:field="*{classification.classId}"></option>
                                </select>
                            </li>
                            <li>
                                <p>授权方：</p>
                                <select id="authorizerId" name="authorizerId">
                                    <option value="">所有</option>
                                    <option th:each="authorizer : ${authorizerList}" th:text="${authorizer.shortName}" th:value="${authorizer.authorizerId}"></option>
                                </select>
                            </li>
                            <li>
                            <p>引入商务：</p>
                                <select id="businessLeader" name="businessLeader">
                                    <option value="">所有</option>
                                    <option th:each="authorizer : ${businessLeaderList}" th:text="${authorizer.businessLeader}" th:value="${authorizer.businessLeader}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <p>创建时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="media:album:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="media:album:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="media:album:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="media:album:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="media:album:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
                <a class="btn btn-primary multiple disabled" onclick="recommendAll()" shiro:hasPermission="media:album:recommend">
                    <i class="fa fa-share-square"></i> 批量推荐
                </a>
                <a class="btn btn-danger multiple disabled" onclick="offLineNotice()" shiro:hasPermission="media:album:offLineNotice">
                    <i class="fa fa-arrow-down"></i> 下线通知
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('media:album:edit')}]];
        var removeFlag = [[${@permission.hasPermi('media:album:remove')}]];
        var recommendFlag= [[${@permission.hasPermi('media:album:recommend')}]];
        var prefix = ctx + "media/album";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                importUrl: prefix + "/importData",
                exportUrl: prefix + "/export",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "专辑",
                detailFormatter: detailFormatter,
                detailView: true,
                class : "",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'albumId',
                    title : 'id',
                    visible: true
                },
                {
                    field : 'cid',
                    title : 'cid',
                    visible: false
                },
                {
                    field : 'title',
                    title : '专辑名称'
                },
                {
                    field : 'description',
                    title : '简介',
                    visible: true,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'director',
                    title : '导演',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'leadingActor',
                    title : '主演',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'className',
                    title : '分类',
                    formatter: function(value, row, index) {
                        return '<span class="badge badge-info"> '+ value + '</span>';
                    }
                },
                {
                    field : 'type',
                    title : '类型',
                    visible: false
                },
                {
                    field : 'langue',
                    title : '语言'
                },
                {
                    field : 'areaName',
                    title : '地区'
                },
                {
                    field : 'score',
                    title : '评分'
                },
                {
                    field : 'episodeAll',
                    title : '总集数'
                },
                {
                    field : 'ageGroup',
                    title : '年龄段',
                    visible: false
                },
                {
                    field : 'times',
                    title : '单集时长',
                    visible: false
                },
                {
                    field : 'allTimesMin',
                    title : '总时长-分钟',
                    visible: false
                },
                {
                    field : 'allTimesHour',
                    title : '总时长-小时',
                    visible: false
                },
                {
                    field : 'resolution',
                    title : '分辨率',
                    visible: false
                },
                {
                    field : 'publishDate',
                    title : '上映日期',
                    visible: false
                },
                {
                    field : 'tag',
                    title : '标签',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>独播</span>';
                        } else if (value == '2') {
                            return '<span>自制</span>';
                        } else if (value == '3') {
                            return '<span>vip</span>';
                        } else if (value == '4') {
                            return '<span>腾讯视频</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'issueLicense',
                    title : '发行许可证',
                    visible: false
                },
                {
                    field : 'makeLicense',
                    title : '制作许可证',
                    visible: false
                },
                {
                    field : 'productionCompany',
                    title : '制作单位',
                    visible: false
                },
                {
                    field : 'theatreInternet',
                    title : '院线/网大',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>院线</span>';
                        } else if (value == '2') {
                            return '<span>网大</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'playPlatform',
                    title : '播出平台',
                    visible: false
                },
                {
                    field : 'classId',
                    title : '分类id',
                    visible: false
                },
                {
                    field : 'authorizerId',
                    title : '授权方id',
                    visible: false
                },
                {
                    field : 'authorizerName',
                    title : '授权方',
                    formatter: function(value, row, index) {
                        return '<span class="badge badge-secondary"> '+ value + '</span>';
                    }
                },
//                {
//                    field : 'authorBeginDate',
//                    title : '授权开始时间'
//                },
                {
                    field : 'authorEndDate',
                    title : '授权截止时间'
                },
                {
                    field : 'isOttCopyright',
                    title : 'ott版权',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>有</span>';
                        } else if (value == '0') {
                            return '<span>没有</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'isIptvCopyright',
                    title : 'iptv版权',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>有</span>';
                        } else if (value == '0') {
                            return '<span>没有</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'copyrightType',
                    title : '版权类型',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>独播</span>';
                        } else if (value == '0') {
                            return '<span>非独播</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'contentLevel',
                    title : '内容等级',
                    visible: false
                },
                {
                    field : 'isProvide',
                    title : '是否可提供',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '2') {
                            return '<span>着重可提供</span>';
                        } else if (value == '1') {
                            return '<span>可提供</span>';
                        } else if (value == '0') {
                            return '<span>不可提供</span>';
                        } else {
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'onlineState',
                    title : '状态',
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span class="badge badge-primary">上线</span>';
                        } else if (value == '0') {
                            return '<span class="badge badge-warning">下线</span>';
                        }
                    }
                },
                {
                    field : 'copyrightRefer',
                    title : '版权参考',
                    visible: false
                },
                {
                    field : 'copyrightInfo',
                    title : '版权信息',
                    visible: false
                },
                {
                    field : 'mobileDisk',
                    title : '移动盘路径',
                    visible: false
                },
                {
                    field : 'serverDisk',
                    title : '服务器路径',
                    visible: false
                },
                {
                    field : 'businessLeader',
                    title : '引入商务',
                    visible: false
                },
                {
                    field : 'purchaseType',
                    title : '采购类型',
                    visible: false,
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span>采购</span>';
                        }else if (value == '2'){
                            return '<span>按月提供</span>';
                        }else if (value == '-1'){
                            return '<span>未知</span>';
                        }
                    }
                },
                {
                    field : 'createTime',
                    title : '创建时间',
                    visible: false,
                    sortable: true
                },
                {
                    field : 'updateTime',
                    title : '修改时间',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + recommendFlag + '" href="javascript:void(0)" onclick="recommend(\'' + row.albumId + '\')"><i class="fa fa-share-square"></i>推荐</a> ');
//                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.albumId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
//                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.albumId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //展开显示
        function detailFormatter(index, row) {
            var html = [];
            $.each(row, function (key, value) {
                if (key != '0' && key != 'params') {
                    if ((key == 'picVtPath' || key == 'picHzPath') && $.common.isNotEmpty(value)) {
                        html.push('<p><b>' + key + ':</b> <a class="btn btn-primary btn-xs" href="javascript:;" onclick="preview(\'' + key + '\', \'' + value + '\')"><i class="fa fa-image"></i>预览图片</a></p>');
                    } else {
                        if (value == null) {
                            value = '-';
                        }
                        html.push('<div style="width:1080px;word-wrap:break-word"><p><b>' + key + ':</b>' + value + '</p></div>');
                    }
                }
            });
            return html.join('');
        }

        //推荐
        function recommend(albumId) {
            var recommendUrl = prefix + "/recommend/" + albumId;
            $.modal.open("推荐专辑", recommendUrl);
        }

        // 批量推荐
        function recommendAll() {
            var rows = $.table.selectColumns("albumId");
            var recommendUrl = prefix + "/recommend/" + rows;
            $.modal.open("推荐专辑", recommendUrl);
        }

        // 下线通知
        function offLineNotice() {
            var rows = $.table.selectColumns("albumId");
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.confirm("确认要通知下线选中的" + rows.length + "条数据吗?", function() {
                $.modal.open("下线通知", prefix + "/offLineNotice/" + rows.join(),400,250);
//                var url = prefix + "/offLineNotice";
//                var data = { "ids": rows.join() };
//                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果专辑已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>